
import java.util.Scanner;

public class Recursion
{
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);//使用Scanner类
        System.out.print("Enter n: ");
        int n = in.nextInt();//定义阶乘的大小*/

        if (n < 0)
        {
            System.out.print("Please enter a whole number that is not less than zero.");
            return;
        }

        for (int i = 0; i <= n; i++) {
            long f = Factorial(i);
            System.out.println(i + "! = " + f);
        }
    }

    public static long Factorial(int n)
   {
          if (n <= 1)
          {
              return 1;
          }
          else return n * Factorial(n - 1);
          }
   }